Skip to content

Conversation

ketsiambaku
Copy link
Contributor

@ketsiambaku ketsiambaku commented Sep 10, 2024

What changed?
Improving the example test by sorting the activities returned by Stats()
The example implementation range over a map and return the result in a slice. Because of this, the assertion against expected result would not always pass since the order is random. This made the test flaky

Why?

How did you test it?
unit tests

Potential risks

Copy link

codecov bot commented Sep 10, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Please upload report for BASE (master@fd9956a). Learn more about missing BASE report.
Report is 1 commits behind head on master.

Additional details and impacted files

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update fd9956a...9da3fea. Read the comment docs.

}
}
sort.Slice(activities, func(i, j int) bool {
return strings.Compare(strings.ToLower(activities[i].Info.ActivityType), strings.ToLower(activities[j].Info.ActivityType)) < 0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorting makes perfect sense, but there's no reason to ToLower here afaict. It'll just make things more ambiguous than they are IRL, where strings need to be identical in both workers and example-test output checks.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed

Copy link
Member

@Groxx Groxx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From the docs on strings.Compare it looks like we can/probably should just use < here... but they appear to be semantically identical so I'll stamp now and land whichever you prefer :) thankfully it's not a locale-sensitive comparison at least.

@ketsiambaku ketsiambaku merged commit 74f6915 into cadence-workflow:master Sep 10, 2024
13 checks passed
@ketsiambaku
Copy link
Contributor Author

From the docs on strings.Compare it looks like we can/probably should just use < here... but they appear to be semantically identical so I'll stamp now and land whichever you prefer :) thankfully it's not a locale-sensitive comparison at least.

I saw the last comment after merging. Followed up in #1367

mrombout pushed a commit to softsense/cadence-client that referenced this pull request Feb 26, 2025
* improve example test by sorting output

* replace slices pkg with sort

* address comments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants